package 剑指offer;

import java.util.Stack;

/**
 * Created by yang on 2016/8/24.
 */
public class StackSimulateQueue {
    Stack<Integer> stack1 = new Stack<Integer>();
    Stack<Integer> stack2 = new Stack<Integer>();

    public void push(int node) {
        stack1.push(node);
    }

    public int pop() {
        int stack1_size = stack1.size();
        for(int i=0;i<stack1_size;i++){
            stack2.push(stack1.pop());
        }
        int p = stack2.pop();
        int stack2_size = stack2.size();
        for(int i = 0;i<stack2_size;i++){
            stack1.push(stack2.pop());
        }
        return p;
    }
}
